/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eproject_sem2;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author h
 */
    public class TableList extends  AbstractTableModel { 
    
    private   Vector colHeaders ;   
    private   Vector tbData ;

    TableList(ResultSet data) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

   
    public void TableList( ResultSet rsData) throws SQLException 
    {
        ResultSetMetaData rsMeta = rsData.getMetaData();    
        
        int count = rsMeta.getColumnCount ( );              

        colHeaders = new Vector(count); 
        tbData = new Vector(); 
                  
        for(int i=1; i <= count; i ++) { 
            colHeaders. addElement (rsMeta. getColumnName (i)); 
                 } 
           
        while ( rsData. next ()) { 
                  
            Vector DataRow = new Vector (count); 
                     
            for (int i = 1; i <= count; i ++) 
            { 
                DataRow.addElement(rsData.getObject(i)); 
            } 
            tbData.addElement(DataRow); 
        } 
    } 
   
    public int getColumnCount () { return colHeaders.size ();     } 
        

    
    public int getRowCount () { return tbData.size ();     } 
        

    public Object getValueAt (int row, int column) { Vector rowData = ( Vector ) (tbData.elementAt (row)); return rowData.elementAt (column);     } 
        
        

  
    @ Override public String getColumnName (int column) { return (String) (colHeaders.elementAt (column));     } }
    
        



    

